use std::{sync::{Arc, Mutex}, thread, time::Duration};
use crate::ltrail::linterface::InitCallback;
use tokio::{self, time::{sleep}};

#[derive(Default)]
pub struct NtpVerObj{
   pub  address:String,
   pub name:String
}


impl NtpVerObj {

   pub  async fn ntp_time(&self, call_back: Arc<Mutex<dyn InitCallback + 'static>>) {
        // tokio::spawn(async move {
        //     println!("打印ntp_time 线程： {:?}", thread::current());
        //     call_back.lock().unwrap().onInitResult(false, 3);
        //     sleep(Duration::from_secs(2)).await;
        // });
        println!("打印ntp_time 线程： {:?}", thread::current());
        sleep(Duration::from_secs(2)).await;

        call_back.lock().unwrap().onInitResult(false, 3);
    
    }

    pub  async fn ntp_time2(&self, call_back: Arc<Mutex<dyn InitCallback + 'static>>) {
        // tokio::spawn(async move {
        //     println!("打印ntp_time 线程： {:?}", thread::current());
        //     call_back.lock().unwrap().onInitResult(false, 3);
        //     sleep(Duration::from_secs(2)).await;
        // });
        println!("打印ntp_time 线程： {:?}", thread::current());
        sleep(Duration::from_secs(2)).await;
        call_back.lock().unwrap().onInitResult(false, 3);
        
    }
}

